//Vote Buying by the United States in the United Nations
//ISQ
//Dan Alexander and Bryan Rooney
*** Data compilation + analysis ***

clear
set more off
clear matrix
clear mata
cd "~/Google Drive/Projects/Vote Buying/US Vote Buying in UN/US UN project"
/*	
* Country name crosswalk
	import delimited "Data/Country Name Crosswalk.csv", clear
		* label variables denoting which files it will help merge, e.g. "to merge PWT" country countryisocode
			label variable countryname "from ideology scores data"
			label variable countryabb "from ideology scores data"
			label variable oldcountryid "from ideology scores data"
			label variable ccode "to merge ideology scores"
			label variable recipientcountry "to merge USAID data"
			label variable unname "to merge UNSC membership"
			label variable country "from PWT"
			label variable countryisocode "to merge PWT data"
			
	drop if ccode==.		
	save un_exint.dta, replace
					
* Existing alternative ``ideology'' measures
	import delimited "Data/Voeten ideology data/IdealpointsPublished.tab", clear	
	tempfile alt_ideology
	save `alt_ideology'
	use un_exint.dta, clear
	merge 1:m ccode using `alt_ideology'
	drop _merge
	* Nauru for whatever reason has two codes throughout some recent period - never in UNSC so no worries dropping it
	drop if countryabb=="NAU" 
	* Note that we'll be attributing funds below to only non-Soviet aligned halves of countries (i.e. not e. germany or s. yemen)
	save un_exint.dta, replace

* Generate propensity to vote with/against the US
	import delimited "Data/Voeten ideology data/UNVotesPublished.tab", clear
	save "Data/votes", replace
		* Yearly measures, all votes
		* NB: Vote: 1=Yes, 2=Abstain, 3=No, 8=Absent, 9=Not a member	
			use "Data/votes", clear
			* Going to start by dropping 8s and 9s, but want 2s, which are abstentions
			replace vote = . if vote==8 | vote==9
			* Generating a ``voted with the US'' variable, ccode==2
			bysort unres: gen usvote = vote if ccode==2
			sort rcid usvote
			bysort rcid: replace usvote = usvote[1]
				* If US did not have a vote above, it won't matter
			drop if usvote==2 | usvote==.
			gen votewithUS = .
			replace votewithUS = 1 if vote == usvote
			replace votewithUS = 0 if vote!=usvote & vote!=2 & vote!=.
			replace votewithUS = 0.5 if vote!=usvote & vote==2
			*keep if (me==1 | di==1 | nu==1)
			*keep if (hr==1 | co==1 | ec==1)
			keep ccode session rcid votewithUS 
			gen year = session + 1945
			drop if votewithUS==.
				* Yemen unified partway through its 1990-91 term and while the voting data recognize this, the other data still have it under its old number
				replace ccode=678 if ccode==679 & year==1991
			tempfile all_votes
			save `all_votes'
			tempfile lat_ideology
			keep if session==0
			drop rcid
			save `lat_ideology'
				* Only the period with 15 members
			set more off		
			forvalues i = 1966/2015 {
				use `all_votes', clear
				keep if year==`i'
				levelsof rcid, local(levels)
				reshape wide votewithUS, i(ccode year) j(rcid)
				* Create an observation of all disagreement		
					local numobs = _N+1
					set obs `numobs'
					replace ccode = 1 in l
					replace year = `i' if ccode==1
					replace session = `i'-1945 if ccode==1
					foreach j in `levels' {
						replace votewithUS`j' = 0 if ccode==1
					}
				reshape long votewithUS, i(ccode year session) j(rcid)
				xi: xtreg votewithUS i.ccode, fe i(rcid)
				predict propvotewithUS_allGA
				append using `lat_ideology'
				save `lat_ideology', replace
			}
			drop *_Icc*
			drop rcid
			drop votewithUS
			collapse propvotewithUS_allGA, by(year ccode session)
			by year: gen adj = -propvotewithUS_allGA[1]
			by year: replace propvotewithUS_allGA = propvotewithUS_allGA + adj
			gen propUS_allGA = round(propvotewithUS_allGA,.001)
			drop adj
			label variable propUS_allGA "Propensity to vote with US (all votes)"
			save propvotewithUS_allGA.dta, replace 
			use un_exint.dta
			merge 1:1 ccode year using propvotewithUS_allGA.dta
			drop _merge
			save un_exint.dta, replace
		
	* security votes
	*import delimited "Data/Voeten ideology data/UNVotesPublished.tab", clear
	*save "Data/votes", replace
		* Yearly measures, all votes
		* NB: Vote: 1=Yes, 2=Abstain, 3=No, 8=Absent, 9=Not a member	
			use "Data/votes", clear
			* Going to start by dropping 8s and 9s, but want 2s, which are abstentions
			replace vote = . if vote==8 | vote==9
			* Generating a ``voted with the US'' variable, ccode==2
			bysort unres: gen usvote = vote if ccode==2
			sort rcid usvote
			bysort rcid: replace usvote = usvote[1]
				* If US did not have a vote above, it won't matter
			drop if usvote==2 | usvote==.
			gen votewithUS = .
			replace votewithUS = 1 if vote == usvote
			replace votewithUS = 0 if vote!=usvote & vote!=2 & vote!=.
			replace votewithUS = 0.5 if vote!=usvote & vote==2
			keep if (me==1 | di==1 | nu==1)
			*keep if (hr==1 | co==1 | ec==1)
			keep ccode session rcid votewithUS 
			gen year = session + 1945
			drop if votewithUS==.
				* Yemen unified partway through its 1990-91 term and while the voting data recognize this, the other data still have it under its old number
				replace ccode=678 if ccode==679 & year==1991
			tempfile all_votes
			save `all_votes'
			tempfile lat_ideology
			keep if session==0
			drop rcid
			save `lat_ideology'
				* Only the period with 15 members
			set more off		
			forvalues i = 1967/2015 {
				use `all_votes', clear
				keep if year==`i'
				levelsof rcid, local(levels)
				reshape wide votewithUS, i(ccode year) j(rcid)
				* Create an observation of all disagreement		
					local numobs = _N+1
					set obs `numobs'
					replace ccode = 1 in l
					replace year = `i' if ccode==1
					replace session = `i'-1945 if ccode==1
					foreach j in `levels' {
						replace votewithUS`j' = 0 if ccode==1
					}
				reshape long votewithUS, i(ccode year session) j(rcid)
				xi: xtreg votewithUS i.ccode, fe i(rcid)
				predict propvotewithUS_secureGA
				append using `lat_ideology'
				save `lat_ideology', replace
			}
			drop *_Icc*
			drop rcid
			drop votewithUS
			collapse propvotewithUS_secureGA, by(year ccode session)
			by year: gen adj = -propvotewithUS_secureGA[1]
			by year: replace propvotewithUS_secureGA = propvotewithUS_secureGA + adj
			gen propUS_secureGA = round(propvotewithUS_secureGA,.001)
			drop adj
			label variable propUS_secureGA "Propensity to vote with US (security votes)"
			save propvotewithUS_secureGA.dta, replace 
			use un_exint.dta
			merge 1:1 ccode year using propvotewithUS_secureGA.dta
			drop _merge
			save un_exint.dta, replace
		
	
	* non-security votes
	*import delimited "Data/Voeten ideology data/UNVotesPublished.tab", clear
	*save "Data/votes", replace
		* Yearly measures, all votes
		* NB: Vote: 1=Yes, 2=Abstain, 3=No, 8=Absent, 9=Not a member	
			use "Data/votes", clear
			* Going to start by dropping 8s and 9s, but want 2s, which are abstentions
			replace vote = . if vote==8 | vote==9
			* Generating a ``voted with the US'' variable, ccode==2
			bysort unres: gen usvote = vote if ccode==2
			sort rcid usvote
			bysort rcid: replace usvote = usvote[1]
				* If US did not have a vote above, it won't matter
			drop if usvote==2 | usvote==.
			gen votewithUS = .
			replace votewithUS = 1 if vote == usvote
			replace votewithUS = 0 if vote!=usvote & vote!=2 & vote!=.
			replace votewithUS = 0.5 if vote!=usvote & vote==2
			*keep if (me==1 | di==1 | nu==1)
			destring ec, replace force
			keep if (hr==1 | co==1 | ec==1)
			keep ccode session rcid votewithUS 
			gen year = session + 1945
			drop if votewithUS==.
				* Yemen unified partway through its 1990-91 term and while the voting data recognize this, the other data still have it under its old number
				replace ccode=678 if ccode==679 & year==1991
			tempfile all_votes
			save `all_votes'
			tempfile lat_ideology
			keep if session==0
			drop rcid
			save `lat_ideology'
				* Only the period with 15 members
			set more off		
			forvalues i = 1966/2015 {
				use `all_votes', clear
				keep if year==`i'
				levelsof rcid, local(levels)
				reshape wide votewithUS, i(ccode year) j(rcid)
				* Create an observation of all disagreement		
					local numobs = _N+1
					set obs `numobs'
					replace ccode = 1 in l
					replace year = `i' if ccode==1
					replace session = `i'-1945 if ccode==1
					foreach j in `levels' {
						replace votewithUS`j' = 0 if ccode==1
					}
				reshape long votewithUS, i(ccode year session) j(rcid)
				xi: xtreg votewithUS i.ccode, fe i(rcid)
				predict propvotewithUS_nonsecGA
				append using `lat_ideology'
				save `lat_ideology', replace
			}
			drop *_Icc*
			drop rcid
			collapse propvotewithUS_nonsecGA, by(year ccode session)
			by year: gen adj = -propvotewithUS_nonsecGA[1]
			by year: replace propvotewithUS_nonsecGA = propvotewithUS_nonsecGA + adj
			gen propUS_nonsecGA = round(propvotewithUS_nonsecGA,.001)
			drop adj
			label variable propUS_nonsecGA "Propensity to vote with US (non-security votes)"
			save propvotewithUS_nonsecGA.dta, replace 
			use un_exint.dta
			merge 1:1 ccode year using propvotewithUS_nonsecGA.dta
			drop _merge
			save un_exint.dta, replace
		
	
* Import funds data
	import delimited "Data/us_foreign_aid_country.csv", clear
	drop current_amount
	drop if fiscal_year=="1976tq"
	destring(fiscal_year), replace
	gen recipientcountry = country_name
	drop if transaction_type_name=="Disbursements"
	drop if country_code=="NULL"
	drop if region_name=="World"
	keep constant_amount recipientcountry fiscal_year assistance_category_name region_name
	reshape wide constant_amount, i(recipientcountry fiscal_year region_name) j(assistance_category_name) string
	rename constant_amountEconomic total_econ_aid
	label variable total_econ_aid "Total Economic Aid"
	rename constant_amountMilitary total_mili_aid
	label variable total_mili_aid "Total Military Aid"
	egen total_total_aid = rowtotal(total_econ_aid total_mili_aid)
	label variable total_total_aid "Total Aid"
	* So that FY2001, which runs from Oct. 2000 to Sept. 2001, is matched to 2000 positions
	gen year = fiscal_year-1
	label variable year "Year"
		
	tempfile usaid
	save `usaid', replace
	
	use un_exint.dta, clear
	drop if recipientcountry==""
	merge 1:m recipientcountry year using `usaid'
	drop _merge
	save un.dta, replace

	use un.dta, clear
	foreach i in total mili econ {
		sort ccode year
		by ccode: gen lag1_`i'_aid = total_`i'_aid[_n-1]
		by ccode: gen lp1_`i'_aid = total_`i'_aid[_n+1]
		by ccode: gen lp2_`i'_aid = total_`i'_aid[_n+2]
	}
	save un.dta, replace
			
			
* Security Council membership
	import delimited "Data/UNSC Membership with FEs.csv", clear 
	label variable countrytermfes "Country-by-term fixed effects"
	label variable rm "Rotating member"
	label variable medimportant "Medium importance year"
	label variable veryimportant "High importance year"
	label variable atallimportant "Important year"
	sort countrytermfes year
	bysort countrytermfes: gen term_year = _n
	gen second_year = term_year==2 if rm==1
	label variable term_year "Year of term"
	label variable second_year "Second year"
	drop if year>=2016
	
	tempfile sc
	save `sc', replace
	
	use un.dta, clear
	drop if unname==""
		* not keeping 1964 observations, for which there aren't ideology measures	
	merge 1:1 unname year using `sc'
	drop _merge
	egen countryXterm = group(countrytermfes)
	save un.dta, replace

* Create lagged values of propUS for SC members
	sort ccode year
	foreach i in all secure nonsec {
		by ccode: gen propUS_`i'GA_evolag = propUS_`i'GA[_n-1]
		label variable propUS_`i'GA_evolag "latent one year back"
	}
	
	sort ccode year
	foreach i in all secure nonsec {
		gen propUS_`i'GA_fixlag = propUS_`i'GA_evolag if rm==1 & second_year==0
		by ccode: replace propUS_`i'GA_fixlag = propUS_`i'GA_fixlag[_n-1] if rm==1 & second_year==1
		label variable propUS_`i'GA_fixlag "latent fixed at year before membership"
	}	
	
	save un.dta, replace
	
* Create rank values
	foreach j in evolag fixlag {
		sort year 
		by year: egen propUS_allGA_`j'_rank = rank(propUS_allGA_`j') if rm==1, field
	}
	label variable propUS_allGA_fixlag_rank "RIP"
	
	gen propUS_allGA_fixlag_rank_sq = propUS_allGA_fixlag_rank^2
	label variable propUS_allGA_fixlag_rank_sq "RIP squared"

	save un.dta, replace

					
* Penn World Tables data on GDP and Population
	use "Data/pwt90_old.dta", clear
	
	rename countrycode countryisocode
	
	label variable pop "Population"
	gen ln_pop = ln(pop*1000)
	label variable ln_pop "Population (ln)"
		* Using expenditure-side real gdp, adjusted for PPP
	label variable cgdpe "GDP per capita"
	destring cgdpe, replace force
	gen ln_gdp_pc = ln(cgdpe)
	label variable ln_gdp_pc "GDP per capita (ln)"
	
	tempfile pwt
	save `pwt', replace
		
	use un.dta, clear
	sort countryisocode year
	quietly by countryisocode year: gen dup = cond(_N==1,0,_n)
	drop if dup>0
	drop dup
	merge 1:1 countryisocode year using `pwt', keep(master match)
	drop _merge
	save un.dta, replace
	
	
*
*** 
*****
***
*  

* Check to make sure have 500 filled out rotating member observations
	sort year countryname
	browse year countryname total_econ_aid total_mili_aid propUS_allGA rm ln_pop ln_gdp_pc  if rm==1 & year>=1966
		* include permanent members
	sort year rm countryname	
	browse year countryname total_econ_aid total_mili_aid propUS_allGA rm ln_pop ln_gdp_pc  if rm!=. & year>=1966

    *
  ***
*****
  ***
    *
	
	
* SOLS data
	use "Data/Bryan data files/CHISOLSstyr4_0.dta", clear
	keep ccode year solschange leadertrans regtrans
	sort ccode year

	tempfile sols
	save `sols'

	use un.dta, clear
	merge 1:1 ccode year using `sols'
	drop _merge
	drop if unname==""

		* These are the potentially problematic cases
			browse if solschange>=1 & solschange!=. & second_year==1 & rm==1
			browse if regtrans>=1 & regtrans!=. & second_year==1 & rm==1
			gen concern=0
			replace concern=1 if solschange>=1 & solschange!=. & second_year==1 & rm==1

	save un.dta, replace
	
* US Mid Data
	use "Data/Bryan data files/Non_Directed_Dispute_1816-2001.dta", clear
	keep if ccode1==2
	rename ccode2 ccode
	keep ccode year
	gen USmid=1
		sort ccode year
		quietly by ccode year:  gen dup = cond(_N==1,0,_n)
		drop if dup>1
		drop dup
	save "Data/MIDUS.dta", replace

	use un.dta, clear
	sort ccode year
	merge 1:1 ccode year using "Data/MIDUS.dta"
	drop if _merge==2
	replace USmid=0 if USmid==.
	drop _merge

	sort ccode year
	by ccode: gen lagmid=USmid[_n-1]
	browse if lagmid==0 & USmid==1
	save un.dta, replace


* US Allies
	import delimited "Data/Bryan data files/2003plus countries.csv", clear
	save "Data/Bryan data files/2003plus_allies.dta", replace
	
	use un.dta, clear
	sort ccode year
	merge 1:m ccode year using "Data/Bryan data files/US_Atop_Allies.dta"
	drop if _merge==2
	replace usally=0 if usally==.
	drop _merge
	
	merge 1:1 unname year using "Data/Bryan data files/2003plus_allies.dta"
	drop if _merge==2
	drop _merge
	replace usally=usallynew if year>=2003
	
	sort ccode year
	by ccode: gen lagally=usally[_n-1]
	browse if lagally==0 & usally==1
	save un.dta, replace

	
* All Conflict
	use "Data/Bryan data files/UCDP.dta", clear
	drop statenme gwname startdate enddate stateabb gwno
		sort ccode year
		quietly by ccode year:  gen dup = cond(_N==1,0,_n)
		drop if dup>1
		drop dup
	
	tempfile UCDP
	save `UCDP'

	use un.dta, clear
	merge 1:1 ccode year using `UCDP'
	drop _merge
	drop if unname==""

	sort ccode year
	by ccode: gen lag_incidence=incidencev414[_n-1]
	by ccode: gen lp_incidence=incidencev414[_n+1]

	save un.dta, replace
	
	
* Polity
	import delimited "Data/Bryan data files/polity4v2015.csv", clear 
	keep ccode year polity2
	label variable polity2 "Polity 2 score"
	sort ccode year
	
	tempfile polity
	save `polity'
	
	use un.dta, clear
	merge 1:1 ccode year using `polity', keep(master match)
	drop _merge
	save un.dta, replace

* IHS	
	use un.dta, clear
	foreach i in total econ mili {
		replace total_`i'_aid = 0 if total_`i'_aid==. & year!=2015
		sort year ccode
		
		gen IHS_`i'_aid = ln(total_`i'_aid+(total_`i'_aid^2+1)^(1/2))
		label variable IHS_`i'_aid "IHS total `i' aid"
	}
	foreach i in total econ mili {
		replace lp1_`i'_aid = 0 if lp1_`i'_aid==. & year!=2015
		sort year ccode
		
		gen IHS_`i'_aid_lp1 = ln(lp1_`i'_aid+(lp1_`i'_aid^2+1)^(1/2))
		label variable IHS_`i'_aid_lp1 "IHS `i' aid (t+1)"
	}
	foreach i in total econ mili {
		replace lp2_`i'_aid = 0 if lp2_`i'_aid==. & (year!=2015 & year!=2014)
		sort year ccode
		
		gen IHS_`i'_aid_lp2 = ln(lp2_`i'_aid+(lp2_`i'_aid^2+1)^(1/2))
		label variable IHS_`i'_aid_lp2 "IHS `i' aid (t+2)"
	}
	save un.dta, replace
	*/	
* Cull to UNSC
	use un.dta, clear
	drop if rm!=1 | year<1966 | year>2006

	foreach i in all secure nonsec {
		bysort year: egen disagr_`i' = total(propUS_`i'GA_fixlag)
		gen cont_disagr_`i' = propUS_`i'GA_fixlag/disagr_`i'
	}
	
	save unsc.dta, replace
	
* DV histograms

	*set scheme s1mono
	hist IHS_mili_aid, xtitle("IHS Military Aid") ti("Distribution of IHS Military Aid") ytitle("Density")
	hist IHS_econ_aid, xtitle("IHS Economic Aid") ti("Distribution of IHS Economic Aid") ytitle("Density")
	hist total_mili_aid, xtitle("Military Aid") ti("Distribution of Military Aid") ytitle("Density")
	hist total_econ_aid, xtitle("Economic Aid") ti("Distribution of Economic Aid") ytitle("Density")

	
* Reality Checks
	sort countryXterm year
	foreach i in IHS_mili_aid IHS_econ_aid cont_disagr_all {
		by countryXterm: gen `i'_up = `i'[_n]>`i'[_n-1]
		by countryXterm: gen `i'_down = `i'[_n]<`i'[_n-1]
		by countryXterm: gen `i'_same = `i'[_n]==`i'[_n-1]
		gen `i'_ch = `i'_up - `i'_down if second_year==1
	}
	
	foreach i in IHS_mili_aid IHS_econ_aid cont_disagr_all {
		reg `i' i.year
		predict yr_`i', residuals

		
		by countryXterm: gen yr_`i'_up = yr_`i'[_n]>yr_`i'[_n-1]
		by countryXterm: gen yr_`i'_down = yr_`i'[_n]<yr_`i'[_n-1]
		by countryXterm: gen yr_`i'_same = yr_`i'[_n]==yr_`i'[_n-1]
		gen yr_`i'_ch = yr_`i'_up - yr_`i'_down if second_year==1
		
		
		by countryXterm: gen yr_`i'_delta = yr_`i'[_n]-yr_`i'[_n-1]
	}
	
	* Number of cases where theory predicts states become relatively more expensive
	count if yr_cont_disagr_all_ch==1 
	* Mili	
		* Number that received more aid
		count if yr_cont_disagr_all_ch==1 & yr_IHS_mili_aid_ch==1
		* Number that were zero aid in second year of term
		count if yr_cont_disagr_all_ch==1 & yr_IHS_mili_aid_ch==-1 & IHS_mili_aid==0
		* Number of those that were not zero aid in first year of term
		count if yr_cont_disagr_all_ch==1 & yr_IHS_mili_aid_ch==-1 & IHS_mili_aid==0 & IHS_mili_aid[_n-1]!=0
	* Econ
		* Number that received more aid
		count if yr_cont_disagr_all_ch==1 & yr_IHS_econ_aid_ch==1
		* Number that were zero aid in second year of term
		count if yr_cont_disagr_all_ch==1 & yr_IHS_econ_aid_ch==-1 & IHS_econ_aid==0
		* Number of those that were not zero aid in first year of term
		*count if yr_cont_disagr_all_ch==1 & yr_IHS_econ_aid_ch==-1 & IHS_econ_aid==0 & IHS_econ_aid[_n-1]!=0

	* Number of cases where theory predicts states become relatively less expensive
	count if yr_cont_disagr_all_ch==-1 
	*count if yr_cont_disagr_all_ch==-1 & propUS_allGA_fixlag_rank<=6
	* Mili
		* Number that received less aid
		count if yr_cont_disagr_all_ch==-1 & yr_IHS_mili_aid_ch==-1
		* Number that were zero aid in first year of term
		count if yr_cont_disagr_all_ch==-1 & yr_IHS_mili_aid_ch==1 & IHS_mili_aid[_n-1]==0
		* Number of those that were not zero aid in second year of term
		count if yr_cont_disagr_all_ch==-1 & yr_IHS_mili_aid_ch==1 & IHS_mili_aid[_n-1]==0 & IHS_mili_aid!=0
	* Econ	
		* Number that received less aid
		count if yr_cont_disagr_all_ch==-1 & yr_IHS_econ_aid_ch==-1
		* Number that were zero aid in first year of term
		count if yr_cont_disagr_all_ch==-1 & yr_IHS_econ_aid_ch==1 & IHS_econ_aid[_n-1]==0
		* Number of those that were not zero aid in second year of term
		count if yr_cont_disagr_all_ch==-1 & yr_IHS_econ_aid_ch==1 & IHS_econ_aid[_n-1]==0 & IHS_econ_aid!=0
	
	* Listing cases		
	sort unname year
	
	* Cases where theory predicts states become relatively more expensive
	list unname year if yr_cont_disagr_all_ch==1 
	* Mili	
		* Number that received more aid
		list unname year if yr_cont_disagr_all_ch==1 & yr_IHS_mili_aid_ch==1
		* Number that were zero aid in second year of term
		list unname year if yr_cont_disagr_all_ch==1 & yr_IHS_mili_aid_ch==-1 & IHS_mili_aid==0
		* Number of those that were not zero aid in first year of term
		list unname year if yr_cont_disagr_all_ch==1 & yr_IHS_mili_aid_ch==-1 & IHS_mili_aid==0 & IHS_mili_aid[_n-1]!=0
	* Econ
		* Number that received more aid
		list unname year if yr_cont_disagr_all_ch==1 & yr_IHS_econ_aid_ch==1
		* Number that were zero aid in second year of term
		list unname year if yr_cont_disagr_all_ch==1 & yr_IHS_econ_aid_ch==-1 & IHS_econ_aid==0
		* Number of those that were not zero aid in first year of term
		list unname year if yr_cont_disagr_all_ch==1 & yr_IHS_econ_aid_ch==-1 & IHS_econ_aid==0 & IHS_econ_aid[_n-1]!=0

	* Cases where theory predicts states become relatively less expensive
	list unname year if yr_cont_disagr_all_ch==-1 
	* Mili
		* Number that received less aid
		list unname year if yr_cont_disagr_all_ch==-1 & yr_IHS_mili_aid_ch==-1
		* Number that were zero aid in first year of term
		list unname year if yr_cont_disagr_all_ch==-1 & yr_IHS_mili_aid_ch==1 & IHS_mili_aid[_n-1]==0
		* Number of those that were not zero aid in second year of term
		list unname year if yr_cont_disagr_all_ch==-1 & yr_IHS_mili_aid_ch==1 & IHS_mili_aid[_n-1]==0 & IHS_mili_aid!=0
	* Econ	
		* Number that received less aid
		list unname year if yr_cont_disagr_all_ch==-1 & yr_IHS_econ_aid_ch==-1
		* Number that were zero aid in first year of term
		list unname year if yr_cont_disagr_all_ch==-1 & yr_IHS_econ_aid_ch==1 & IHS_econ_aid[_n-1]==0
		* Number of those that were not zero aid in second year of term
		list unname year if yr_cont_disagr_all_ch==-1 & yr_IHS_econ_aid_ch==1 & IHS_econ_aid[_n-1]==0 & IHS_econ_aid!=0
		
	twoway scatter yr_IHS_mili_aid_delta yr_cont_disagr_all_delta, ytitle("Change in IHS Military Aid") xtitle("Change in Contribution to Disagreement") mlabel(countryabb) m(i) //|| lfit yr_IHS_mili_aid_delta yr_cont_disagr_all_delta, legend(off)
	twoway scatter yr_IHS_econ_aid_delta yr_cont_disagr_all_delta, ytitle("Change in IHS Military Aid") xtitle("Change in Contribution to Disagreement") || lfit yr_IHS_mili_aid_delta yr_cont_disagr_all_delta, legend(off)
	twoway scatter yr_IHS_mili_aid_delta yr_cont_disagr_all_delta if propUS_allGA_fixlag_rank<=6, ytitle("Change in IHS Military Aid") xtitle("Change in Contribution to Disagreement") || lfit yr_IHS_mili_aid_delta yr_cont_disagr_all_delta if propUS_allGA_fixlag_rank<=6, legend(off)
	twoway scatter yr_IHS_econ_aid_delta yr_cont_disagr_all_delta if propUS_allGA_fixlag_rank<=6, ytitle("Change in IHS Military Aid") xtitle("Change in Contribution to Disagreement") || lfit yr_IHS_mili_aid_delta yr_cont_disagr_all_delta if propUS_allGA_fixlag_rank<=6, legend(off)
	
	
*** Regressions	
	
	label variable solschange "Ruling Coalition Shift"
	label variable usally "Alliance with US"
	label variable USmid "MID with US"
	label variable propUS_allGA_fixlag_rank "RIP"
	label variable second_year "Second Year"
	label variable IHS_mili_aid "Military Aid (IHS)"
	label variable IHS_econ_aid "Economic Aid (IHS)"
	label variable cont_disagr_all "Contribution to Disagreement"
	label variable cont_disagr_secure "Contribution to Disagreement (UNGA security votes)"
	label variable cont_disagr_nonsec "Contribution to Disagreement (UNGA non-security votes)"
	label variable polity2 "Polity Score"
	
* Main specifications
	
	global Y "propUS_allGA_fixlag_rank<=6 &"
	global YR "year<=2006"
	
	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0)
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0)
	
	estout using "mili_aid.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
	
	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_econ_aid cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	eststo:	tobit IHS_econ_aid cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_econ_aid cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0)
	eststo:	tobit IHS_econ_aid cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0)

	estout using "econ_aid.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	

	global Y "propUS_allGA_fixlag_rank<=6 &"
	global YR "year<=2006"
	
	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	margins, dydx(cont_disagr_all) at(cont_disagr_all=(.1010309 .1463847))
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0)
	
	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_econ_aid cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_econ_aid cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0)
	
		
* Democracy Autocracy		
		
	gen dem_state = polity2>=6 
	label variable dem_state "Democratic state (Polity$\geq$6)"
	gen dem_state_cont_disagr_all = dem_state*cont_disagr_all
	label variable dem_state_cont_disagr_all "Contribution to disagreement $\times$ dem. state"
	
	estimates clear
	global X "solschange USmid second_year" 
	eststo:	tobit IHS_mili_aid dem_state cont_disagr_all dem_state_cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_mili_aid dem_state cont_disagr_all dem_state_cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	global X "solschange USmid second_year usally" 
	eststo:	tobit IHS_mili_aid dem_state cont_disagr_all dem_state_cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_mili_aid dem_state cont_disagr_all dem_state_cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0) 

	estout using "mili_aid_demvaut.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all dem_state dem_state_cont_disagr_all $X _cons) ///
		order(cont_disagr_all dem_state dem_state_cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace

	estimates clear
	global X "solschange USmid second_year" 
	eststo:	tobit IHS_econ_aid dem_state cont_disagr_all dem_state_cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_econ_aid dem_state cont_disagr_all dem_state_cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	global X "solschange USmid second_year usally" 
	eststo:	tobit IHS_econ_aid dem_state cont_disagr_all dem_state_cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_econ_aid dem_state cont_disagr_all dem_state_cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0) 

	estout using "econ_aid_demvaut.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all dem_state dem_state_cont_disagr_all $X _cons) ///
		order(cont_disagr_all dem_state dem_state_cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace		


* Other cutpoints

	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if propUS_allGA_fixlag_rank<=5 & $YR, vce(robust) ll(0) 
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if propUS_allGA_fixlag_rank<=7 & $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if propUS_allGA_fixlag_rank<=8 & $YR, vce(robust) ll(0) 

	estout using "cut_mili_aid.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 5" "Rank $\leq$ 7" "Rank $\leq$ 8", pattern(1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
		
	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_econ_aid cont_disagr_all $X i.year i.countryXterm if propUS_allGA_fixlag_rank<=5 & $YR, vce(robust) ll(0) 
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_econ_aid cont_disagr_all $X i.year i.countryXterm if propUS_allGA_fixlag_rank<=7 & $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_econ_aid cont_disagr_all $X i.year i.countryXterm if propUS_allGA_fixlag_rank<=8 & $YR, vce(robust) ll(0) 

	estout using "cut_econ_aid.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 5" "Rank $\leq$ 7" "Rank $\leq$ 8", pattern(1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
		

* Placebo tests		
			
	label var	IHS_econ_aid_lp1 "Economic Aid (T+1)"
	label var	IHS_mili_aid_lp1 "Military Aid (T+1)"
	
	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_mili_aid_lp1 cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_mili_aid_lp1 cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_mili_aid_lp1 cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_mili_aid_lp1 cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0) 
	
		estout using "placebo_mili_aid.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
		
	estimates clear
	global X "solschange polity2 USmid second_year" 
	eststo:	tobit IHS_econ_aid_lp1 cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_econ_aid_lp1 cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_econ_aid_lp1 cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0) 
	eststo:	tobit IHS_econ_aid_lp1 cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0) 
	
		estout using "placebo_econ_aid.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
		
	
* %-age GDP
	gen mili_aid_gdp=(total_mili_aid/cgdpe)
	gen econ_aid_gdp=(total_econ_aid/cgdpe)

	estimates clear
	global X "solschange polity2 second_year" 
	eststo:	tobit mili_aid_gdp cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	eststo:	tobit mili_aid_gdp cont_disagr_all $X  i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	global X "solschange polity2 second_year USmid usally" 
	eststo:	tobit mili_aid_gdp cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0) 
	eststo:	tobit mili_aid_gdp cont_disagr_all $X  i.year i.countryXterm if $YR, vce(robust) ll(0) 
		estout using "mili_aid_gdp.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace

	estimates clear
	global X "solschange polity2 second_year" 
	eststo:	tobit econ_aid_gdp cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	eststo:	tobit econ_aid_gdp cont_disagr_all $X i.year i.countryXterm if $Y $YR, vce(robust) ll(0) 
	global X "solschange polity2 second_year USmid usally" 
	eststo:	tobit econ_aid_gdp cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0) 
	eststo:	tobit econ_aid_gdp cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0) 
		estout using "econ_aid_gdp.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace

* Coldwar restriction

	global YR "year<=1991"
	
	estimates clear
	global X "solschange polity2 USmid" 
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm $X if $Y $YR, vce(robust) ll(0)
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0)
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0)
	
	estout using "mili_aid_cold.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace		

	global YR "year>1991 & year<=2006"
	
	estimates clear
	global X "solschange polity2 USmid" 
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm if $Y $YR, vce(robust) ll(0)
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm $X if $Y $YR, vce(robust) ll(0)
	global X "solschange polity2 USmid second_year usally" 
	eststo:	tobit IHS_mili_aid cont_disagr_all i.year i.countryXterm if $YR, vce(robust) ll(0)
	eststo:	tobit IHS_mili_aid cont_disagr_all $X i.year i.countryXterm if $YR, vce(robust) ll(0)
	
	estout using "mili_aid_pcold.tex", ///
		cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N, fmt(%9.0f) labels("N")) ///
		eqlabels(none) collabels(none) style(tex) starlevels(* .10 ** .05 *** .01) label ///
		mgroups("Rank $\leq$ 6" "Rank $\leq$ 6" "All Non-Permanent Members" "All Non-Permanent Members", pattern(1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		keep(cont_disagr_all $X _cons) ///
		order(cont_disagr_all $X  _cons) ///
		varlabels(_cons "Constant", elist(_cons "\addlinespace Fixed Effects & Yes & Yes & Yes & Yes \\")) ///
		mlabels("(1)" "(2)" "(3)" "(4)") ///
		prehead("\resizebox{\textwidth}{!}{" "\begin{tabular}{{l}*{@M}{c}}" "\hline") ///
		posthead(\hline) prefoot(\hline) ///
		postfoot("\hline" "\end{tabular}" "}") replace	
		

